<template>
  <div class="contarner-page" @click.stop="showLanguageHandel">
    <page-header ref="languageRef"></page-header>
    <main>
      <div class="downloader flex_ccenter" v-if="!success">
        <div class="container">
          <div class="hero-widgets flex_between c-fff">
            <div class="tool-item shou flex_center" @click="changeTab(0)">
              <img src="/static/images/video.svg" alt="savinginsta video" />
              <span class="f-16">Video</span>
            </div>
            <div class="tool-item shou flex_center" @click="changeTab(1)">
              <img src="/static/images/Photo.svg" alt="savinginsta photo" />
              <span class="f-16">Photo</span>
            </div>
            <div class="tool-item shou flex_center" @click="changeTab(2)">
              <img src="/static/images/Reels.svg" alt="savinginsta reels" />
              <span class="f-16">Reels</span>
            </div>
            <div class="tool-item shou flex_center" @click="changeTab(3)">
              <img src="/static/images/Story.svg" alt="savinginsta story" />
              <span class="f-16">Story</span>
            </div>
            <div class="tool-item shou flex_center" @click="changeTab(4)">
              <img src="/static/images/Igtv.svg" alt="savinginsta IGTV" />
              <span class="f-16">IGTV</span>
            </div>
          </div>
          <div class="banner-heading flex_ccenter">
            <div class="heading-item" v-show="current == 0">
              <h1 class="title fw700 f-42 c-fff">Unduh Video Instagram</h1>
              <h2 class="sub c-fff f-18 fw400">
                Download Video Instagram, Foto, Gulungan, Cerita, lan IGTV
                Konten Online
              </h2>
            </div>
            <div class="heading-item" v-show="current == 1">
              <nuxt-link to="/jv/instagram-photo-download">
                <div @click="goToTop('Photo')" class="tItem">
                  <h3 class="title fw700 f-42 c-fff shou">
                    Instagram Photo Downloader
                  </h3>
                </div>
              </nuxt-link>
              <p class="sub c-fff f-18 fw400">
                Ketik URL FOTO Instagram ing ngisor iki
              </p>
            </div>
            <div class="heading-item" v-show="current == 2">
              <nuxt-link to="/jv/instagram-reels-video-download">
                <div @click="goToTop('reels')" class="tItem">
                  <h3 class="title fw700 f-42 c-fff shou">
                    Unduh Instagram Reels
                  </h3>
                </div>
              </nuxt-link>
              <p class="sub c-fff f-18 fw400">
                Ketik URL Instagram Reels ing ngisor iki
              </p>
            </div>
            <div class="heading-item" v-show="current == 3">
              <nuxt-link to="/jv/instagram-story-download">
                <div @click="goToTop('story')" class="tItem">
                  <h3 class="title fw700 f-42 c-fff shou">
                    Unduh Instagram Story
                  </h3>
                </div>
              </nuxt-link>
              <p class="sub c-fff f-18 fw400">
                Ketik URL Instagram Stories ing ngisor iki
              </p>
            </div>
            <div class="heading-item" v-show="current == 4">
              <nuxt-link to="/jv/igtv-downloader">
                <div @click="goToTop('igtv')" class="tItem">
                  <h3 class="title fw700 f-42 c-fff shou">Unduh Video IGTV</h3>
                </div>
              </nuxt-link>
              <p class="sub c-fff f-18 fw400">
                Ketik URL IGTV Instagram ing ngisor iki
              </p>
            </div>
          </div>
          <div class="form flex_center">
            <div class="input-box flex_between">
              <!-- <input
                type="text"
                class="input f-18"
                v-model="input"
                @input="handleInput"
                @paste="handleInput"
                placeholder="Paste URL Instagram"
                list="fruits"
                name="fruit"
              />
              <datalist id="fruits">
                <option value="Apple"></option>
                <option value="Banana"></option>
                <option value="Cherry"></option>
              </datalist> -->
              <input
                type="text"
                class="input f-18"
                v-model="input"
                :disabled="isHttpLoading"
                @input="handleInput"
                @paste="handleInput"
                @keydown="sendDownload($event)"
                placeholder="Paste URL Instagram"
              />
              <div
                class="Paste shou flex_center"
                @click="handleClickPasted"
                v-if="input == ''"
              >
                <div class="btnbg"></div>
                <div class="f-16 c-000 fw700">Paste</div>
              </div>
              <div
                class="clear shou flex_center"
                v-if="input != '' && !isHttpLoading"
                @click.stop="input = ''"
              >
                <div class="btnbg"></div>
                <div class="f-16 c-000 fw700">Clear</div>
              </div>
            </div>
            <div
              v-if="!isHttpLoading"
              @click.stop="downloadHandel"
              class="submit shou fw700 c-fff flex_center"
            >
              Download
            </div>
            <div v-else class="submit shou fw700 c-fff flex_center">
              Please wait
            </div>
          </div>
          <div class="app-submit flex_ccenter">
            <div
              class="submit flex_center"
              v-if="!isHttpLoading"
              @click.stop="downloadHandel"
            >
              <div class="fw700 c-fff f-21">Download</div>
            </div>
            <div class="submit flex_center" v-else>
              <div class="fw700 c-fff f-21">Please wait</div>
            </div>
          </div>
          <div class="loading" v-if="isHttpLoading">
            <div class="loading-dots flex_center">
              <div class="dot"></div>
              <div class="dot"></div>
              <div class="dot"></div>
              <div class="dot"></div>
            </div>
            <div class="tips f-18 flex_center">
              <div>Njupuk data, mangga ngenteni sawetara detik!</div>
            </div>
          </div>
          <div class="error flex_ccenter" v-if="httpError1">
            <div class="hono flex_">
              <div class="error-img"></div>
              <div class="error-img"></div>
              <div class="error-img"></div>
            </div>
            <div class="errMsg f-18">
              Situs kasebut ora bisa ngolah link sampeyan amarga iku pribadi
            </div>
          </div>
          <div class="error flex_ccenter" v-if="httpError2">
            <div class="hono flex_">
              <div class="error-img"></div>
              <div class="error-img"></div>
              <div class="error-img"></div>
            </div>
            <div class="errMsg f-18">
              Data sing sampeyan lebokake dudu link. Mangga ketik link bener,
              kanggo contone:
              <div>https://www.instagram.com/reel/Cml9qu-ISqx</div>
            </div>
          </div>
        </div>
      </div>
      <!-- 广告位start -->
      <!-- 广告位end -->
      <div class="container" v-if="!success">
        <div class="body-content">
          <div class="title-box">
            <h3 class="title f-36 c-000 italic">
              Kabeh fitur saka Savinginsta.Com
            </h3>
            <p class="sub f-16 c-ccc">
              Savinginsta kompatibel karo kabeh jinis video Instagram
               lan pranala gambar.
            </p>
          </div>
          <div class="list-tools-pc">
            <div class="tool-box flex_between">
              <div class="tool-info">
                <nuxt-link to="/jv">
                  <div @click="goToTop('video')" class="tItem">
                    <h4>Ngundhuh video Instagram</h4>
                  </div>
                </nuxt-link>
                <p>
                  Savinginsta dirancang supaya sampeyan bisa ndownload dhewe
                   konten saka Instagram. Nawakake dhukungan kanggo ngundhuh loro-lorone
                   individu lan sawetara video saka Insta.
                </p>
              </div>
              <div class="tool-thumb">
                <img
                  src="/static/images/instagram-video-downloader.webp"
                  alt="Instagram video downloader"
                />
              </div>
              <div class="tool-thumb-app">
                <img
                  src="/static/images/instagram-video-downloader-app.webp"
                  alt="Instagram video downloader"
                />
              </div>
            </div>
            <div class="tool-box tool-reverse flex_between">
              <div class="tool-info">
                <nuxt-link to="/jv/instagram-photo-download">
                  <div @click="goToTop('Photo')" class="tItem">
                    <h4>Ngundhuh foto Instagram</h4>
                  </div>
                </nuxt-link>
                <p>
                  Ngundhuh Foto Instagram Savinginsta nggawe gampang
                   kanggo nyimpen foto siji utawa pirang-pirang, kalebu kolase,
                   saka Instagram. Kanthi alat iki, ndownload kiriman individu
                   gambar utawa koleksi foto Instagram prasaja lan
                   terus terang.
                </p>
              </div>
              <div class="tool-thumb">
                <img
                  loading="lazy"
                  src="/static/images/instagram-photo-downloader.webp"
                  alt="Instagram photo downloader"
                />
              </div>
              <div class="tool-thumb-app">
                <img
                  loading="lazy"
                  src="/static/images/instagram-photo-downloader-app.webp"
                  alt="Instagram photo downloader"
                />
              </div>
            </div>
            <div class="tool-box flex_between">
              <div class="tool-info">
                <nuxt-link to="/jv/instagram-reels-video-download">
                  <div @click="goToTop('reels')" class="tItem">
                    <h4>Unduh Instagram Reels</h4>
                  </div>
                </nuxt-link>
                <p>
                  Savinginsta's Instagram Reels Downloader ngidini sampeyan
                   effortlessly download Reels video saka kiriman Instagram kanggo
                   piranti sampeyan, nyediakake solusi prasaja ngendi Instagram
                   dhewe nawakake ora support kanggo fungsi iki.
                </p>
              </div>
              <div class="tool-thumb">
                <img
                  loading="lazy"
                  src="/static/images/download-instagram-reels.webp"
                  alt="Download Instagram Reels"
                />
              </div>
              <div class="tool-thumb-app">
                <img
                  loading="lazy"
                  src="/static/images/download-instagram-reels-app.webp"
                  alt="Download Instagram Reels"
                />
              </div>
            </div>
            <div class="tool-box tool-reverse flex_between">
              <div class="tool-info">
                <nuxt-link to="/jv/igtv-downloader">
                  <div @click="goToTop('igtv')" class="tItem">
                    <h4>IGTV ngundhuh</h4>
                  </div>
                </nuxt-link>
                <p>
                  Kisah Instagram nawakake platform khusus kanggo pangguna
                   nuduhake pengalaman saben dina liwat foto lan video karo a
                   pamirsa amba. Kadhangkala, sampeyan pengin nyimpen favorit
                   crita, nanging fungsi iki ora kasedhiya ing app.
                   Savinginsta ngatasi masalah iki kanthi menehi solusi kasebut
                   ngidini pangguna ndownload lan ndeleng crita Instagram kanthi gampang
                   offline, mesthekake yen isi paweling tau ilang.
                </p>
              </div>
              <div class="tool-thumb">
                <img
                  loading="lazy"
                  src="/static/images/igtv-downloader.webp"
                  alt="IGTV downloader"
                />
              </div>
              <div class="tool-thumb-app">
                <img
                  loading="lazy"
                  src="/static/images/igtv-downloader-app.webp"
                  alt="IGTV downloader"
                />
              </div>
            </div>
            <div class="tool-box flex_between">
              <div class="tool-info">
                <nuxt-link to="/jv/instagram-story-download">
                  <div @click="goToTop('story')" class="tItem">
                    <h4>Instagram Story Viewer</h4>
                  </div>
                </nuxt-link>
                <p>
                  IGTV nawakake video dawa, lan yen sampeyan ora bisa
                   ndeleng langsung, sampeyan duwe pilihan kanggo ngundhuh iki
                   video IGTV menyang PC. Iki ngidini sampeyan nyaman
                   ngunjungi maneh lan nikmati mengko, sanajan tanpa internet
                   sambungan, lan ngilangake uneg-uneg babagan isi IGTV
                   dibusak utawa ora kasedhiya.
                </p>
              </div>
              <div class="tool-thumb">
                <img
                  loading="lazy"
                  src="/static/images/instagram-story-download.webp"
                  alt="Instagram Story Download"
                />
              </div>
              <div class="tool-thumb-app">
                <img
                  loading="lazy"
                  src="/static/images/instagram-story-download-app.webp"
                  alt="Instagram Story Download"
                />
              </div>
            </div>
          </div>
          <div class="app-box">
            <div class="app-box__info">
              <h3 class="app-box__title f-21 fw700 c-000">
                Download nganggo aplikasi Insta Downloader
              </h3>
              <p class="f-16 c-ccc">
                Aplikasi kita nawakake solusi sing cepet lan gampang kanggo ndownload
                 Video Instagram, nyedhiyakake video kualitas HD tanpa
                 tandha banyu.
              </p>
            </div>
            <div class="app-link">
              <a 
                  target="_blank" href="https://play.google.com/store/apps/details?id=ins.freevideodownload.pro">
                <img src="/static/images/google-play.webp" alt="Download app " />
              </a>
              <a href="https://apps.apple.com/us/app/repost-for-video-save-story/id6462401460"  target="_blank">
                <img src="/static/images/IOS.webp" alt="Download app " />
              </a>
            </div>
          </div>
          <div class="quick-info">
            <h3 class="f-32 c-000">
              SAVINGINSTA - DOWNLOADER TOOL INSTAGRAM paling apik
            </h3>
            <p class="f-16 c-ccc">
              Savinginsta minangka pangunduh Instagram paling dhuwur,
               pakar digawe kanggo cepet ngundhuh konten kualitas dhuwur saka
               Instagram. Nalika nggoleki cara sing paling efektif kanggo ngundhuh
               Media Instagram, Savinginsta downloader muncul minangka pimpinan
               solusi pihak katelu.
            </p>
            <p class="f-16 c-ccc">
              Instagram, misuwur minangka aplikasi enggo bareng foto sing paling populer ing donya,
               nyekseni unggahan jutaan foto saben dina. Kanggo kuwi
               wayahe, kabutuhan ngundhuh video Instagram dadi
               bukti, nyediakake solusi rapi kanggo kabutuhan langsung.
               Alat iki penting kanggo sapa wae sing pengin njaga
               konten Instagram favorit kanthi efisien.
            </p>
          </div>
          <div class="features c-fff">
            <h3 class="h3 fw700 f-21">
              Fitur Savinginsta Instagram Video Downloader:
            </h3>
            <div class="attributes-list flex_between">
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Download video Instagram Cepet, gampang lan aman.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Sampeyan bisa metu saka akun Instagram.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Kanthi mung klik tombol, sampeyan bisa ndownload gambar Instagram
                   lan video.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Ngundhuh lan nyimpen gambar lan video ing dhuwur asline
                   definisi lan kualitas.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Saka akun pribadi, download lan simpen video Instagram.
                </div>
              </div>
              <div class="item flex_">
                <div class="bgimg"></div>
                <div class="f-14 c-fff">
                  Kacepetan dhuwur: Saiki, Savinginsta nawakake paling cepet
                   kacepetan download.
                </div>
              </div>
            </div>
          </div>
          <div class="how">
            <div class="how-title">
              <h3 class="f-36 c-000 italic">
                Cara nggunakake Savinginsta Instagram Downloader kanggo nyimpen saka IG
              </h3>
              <div class="note c-ccc f-16">
                Cathetan: Priksa manawa video utawa foto Instagram sing dikarepake
                 download saka akun umum.
              </div>
            </div>
            <div class="steps">
              <div class="step">
                <div class="one">
                  <span class="fw700 c-blue f-16">Langkah01:</span>
                  <span class="f-16 c-000"
                    >Nyalin URL Foto & Video Instagram</span
                  >
                </div>
                <div class="app-step">
                  <div class="fw700 c-000 f-16">Ing aplikasi Instagram:</div>
                  <div class="c-000 f-16">
                    Kanggo iOS: Tutul kanggo njupuk URL foto Instagram.
                  </div>
                  <div class="c-000 f-16">
                    Kanggo Android: Klik ing ndhuwur kiriman banjur pilih 'Salin
                     URL Instagram', banjur pencet 'Salin Share URL'. Link bakal
                     disalin menyang clipboard sampeyan.
                  </div>
                  <div class="fw700 c-000 f-16">- Ing PC / Mac:</div>
                  <div class="c-000 f-16">
                    Klik-tengen ing tanggal video utawa foto Instagram lan
                     pilih "Salin Alamat Link" kanggo ndownload konten Instagram
                     desktop sampeyan.
                  </div>
                </div>
              </div>
              <div class="step">
                <div class="one">
                  <span class="fw700 c-blue f-16">Langkah02:</span>
                  <span class="f-16 c-000">
                    Tempel URL menyang Savinginsta.App</span
                  >
                </div>
                <div class="app-step">
                  <div class="c-000 f-16">
                    Navigasi menyang Savinginsta.App - Instagram khusus
                     ngundhuh.
                  </div>
                  <div class="c-000 f-16">
                    Salin lan tempel URL sing disalin menyang kolom teks sing diwenehake.
                  </div>
                </div>
              </div>
              <div class="step">
                <div class="one">
                  <span class="fw700 c-blue f-16">Langkah03:</span>
                  <span class="f-16 c-000">Miwiti Download</span>
                </div>
                <div class="app-step">
                  <div class="c-000 f-16">
                    Klik tombol "Download" kanggo miwiti video Instagram utawa
                     proses download foto.
                  </div>
                  <div class="fw700 c-000 f-16">
                    Informasi Panggunaan Penting
                  </div>
                  <div class="c-000 f-16">
                    Savinginsta dirancang utamane kanggo ndownload video lan
                     gambar saka akun Instagram sampeyan dhewe.
                  </div>
                  <div class="c-000 f-16">
                    Kita prioritas privasi pangguna lan duwe hak kanggo nolak
                     layanan yen alat kita digunakake kanggo nglanggar wong liya
                     privasi utawa kanggo ngakses materi sing ora sah.
                  </div>
                </div>
              </div>
            </div>
            <div class="user-note f-16">
              <div class="app-tip"></div>
              Kanggo pemahaman lengkap babagan kabijakan kita

              <a class="fw700 c-blue" href="/terms-of-service">
                waca Ketentuan Layanan lengkap ing kene.</a
              >
            </div>
          </div>
          <div class="faq-section">
            <h3 class="faq-title f-36 c-000 italic">FAQ</h3>
            <div class="accordion">
              <div
                id="faq"
                itemscope="itemscope"
                itemtype="https://schema.org/FAQPage"
              >
                <div
                  itemprop="mainEntity"
                  itemscope="itemscope"
                  itemtype="https://schema.org/Question"
                  class="accordion-item"
                  :key="k"
                  v-for="(item, k) in faqList"
                >
                  <h4 itemprop="name" class="accordion-title fw700 f-16">
                    {{ item.title }}
                  </h4>
                  <div
                    itemprop="acceptedAnswer"
                    itemscope=""
                    itemtype="https://schema.org/Answer"
                  >
                    <div
                      itemprop="text"
                      class="accordion-text f-16 c-ccc fw400"
                    >
                      {{ item.content }}
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 解析结果 start -->
      <div class="container" v-if="success">
        <success-content
          @refresh="refresh"
          :list="successList"
        ></success-content>
      </div>
      <!-- 解析结果 end -->
    </main>
    <footer>
      <div class="container">
        <div class="footer-content">
          <div class="footer-link">
            <div class="row flex_between">
              <div class="col-12">
                <div class="link-label fw700 c-000 f-21">piranti</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li @click="goToTools('story')">
                    <nuxt-link to="/jv/instagram-story-download"
                      >Instagram Story Downloader</nuxt-link
                    >
                  </li>
                  <li @click="goToTools('reels')">
                    <nuxt-link to="/jv/instagram-reels-video-download"
                      >Instagram Reels Downloader</nuxt-link
                    >
                  </li>
                  <li>
                    <a href="https://savingtik.com/" target="_blank"
                      >Tiktok Downloader</a
                    >
                  </li>
                </ul>
              </div>
              <div class="col-6">
                <div class="link-label fw700 c-000 f-21">Nyokong</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li>
                    <nuxt-link to="/contact"> Kontak </nuxt-link>
                  </li>
                  <li>
                    <nuxt-link to="/blog"> Blog </nuxt-link>
                  </li>
                </ul>
              </div>
              <div class="col-6">
                <div class="link-label fw700 c-000 f-21">sah</div>
                <ul class="list-unstyled c-ccc f-16">
                  <li>
                    <nuxt-link to="/terms-of-service">
                      Ketentuan Layanan
                    </nuxt-link>
                  </li>
                  <li>
                    <nuxt-link to="/privacy-policy"> Kebijakan Privasi </nuxt-link>
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <div class="copyright flex_ccenter">
            <b class="fw700 f-21 c-000"
              >Kita ora afiliasi karo Instagram utawa Meta</b
            >
            <div class="c-ccc f-16">
              © {{new Date().getFullYear()}} Insta Downloader All rights reserved.
            </div>
          </div>
        </div>
      </div>
    </footer>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations } from "vuex";
import pageHeader from "~/components/page-header.vue";
import SuccessContent from "~/components/success-content.vue";
import CryptoJS from "crypto-js";
import { handleClick, checkString } from "@/plugins/Firebase.js";

export default {
  components: { pageHeader, SuccessContent },
  name: "IndexPage",
  head: {
    htmlAttrs: {
      lang: "jv",
    },
    bodyAttrs: {
      "data-lang": "jv",
    },
    title:
      "Instagram Downloader - Download Instagram Video online - Savinginsta",
    meta: [
      { property: "og:locale", content: "jv" },
      //Page Information
      {
        name: "description",
        content:
          "Savinginsta: Ngundhuh video, gulungan, lan foto Instagram kanthi gampang nganggo alat sing ramah pangguna. Simpen video Instagram kanthi cepet lan aman ing piranti apa wae.",
      },
      //Schema.org Microdata
      {
        itemprop: "name",
        content:
          "Instagram Downloader - Download Instagram Video online - Savinginsta",
      },

      // Facebook / OpenGraph
      {
        property: "og:title",
        content:
          "Instagram Downloader - Download Instagram Video online - Savinginsta",
      },
      { property: "og:type", content: "website" },
      { property: "og:url", content: "https://savinginsta.com/jv" },

      {
        property: "og:description",
        content:
          "Savinginsta: Ngundhuh video, gulungan, lan foto Instagram kanthi gampang nganggo alat sing ramah pangguna. Simpen video Instagram kanthi cepet lan aman ing piranti apa wae.",
      },
      //Twitter
      { name: "twitter:card", content: "summary" },
      { name: "twitter:url", content: "https://savinginsta.com/jv" },
      {
        name: "twitter:title",
        content:
          "Instagram Downloader - Download Instagram Video online - Savinginsta",
      },
      {
        name: "twitter:description",
        content:
          "Savinginsta: Ngundhuh video, gulungan, lan foto Instagram kanthi gampang nganggo alat sing ramah pangguna. Simpen video Instagram kanthi cepet lan aman ing piranti apa wae.",
      },
      //multilingual
      {
        name: "google",
        content: "notranslate",
      },
      {
        itemprop: "image",
        content: "https://savinginsta.com/static/images/savinginsta_thumbnail.jpg",
      },
      {
        property: "og:image",
        content: "https://savinginsta.com/static/images/savinginsta_thumbnail.jpg",
      },
      {
        name: "twitter:image",
        content: "https://savinginsta.com/static/images/savinginsta_thumbnail.jpg",
      },
    ],
    link: [
      //multilingual
      {
        rel: "alternate",
        hreflang: "x-default",
        href: "https://savinginsta.com/jv",
      },
      {
        rel: "alternate",
        hreflang: "en",
        href: "https://savinginsta.com/",
      },
      {
        rel: "alternate",
        hreflang: "en-in",
        href: "https://savinginsta.com/in",
      },
      {
        rel: "alternate",
        hreflang: "vi",
        href: "https://savinginsta.com/vn",
      },
      {
        rel: "alternate",
        hreflang: "tr",
        href: "https://savinginsta.com/tr",
      },
      {
        rel: "alternate",
        hreflang: "id",
        href: "https://savinginsta.com/id",
      },
      {
        rel: "alternate",
        hreflang: "fr",
        href: "https://savinginsta.com/fr",
      },
      {
        rel: "alternate",
        hreflang: "pt",
        href: "https://savinginsta.com/pt",
      },
      {
        rel: "alternate",
        hreflang: "ru",
        href: "https://savinginsta.com/ru",
      },
      {
        rel: "alternate",
        hreflang: "es",
        href: "https://savinginsta.com/es",
      },
      {
        rel: "alternate",
        hreflang: "ms",
        href: "https://savinginsta.com/ms",
      },
      {
        rel: "alternate",
        hreflang: "ko",
        href: "https://savinginsta.com/ko",
      },
      {
        rel: "alternate",
        hreflang: "ja",
        href: "https://savinginsta.com/ja",
      },
      {
        rel: "alternate",
        hreflang: "jv",
        href: "https://savinginsta.com/jv",
      },
      {
        rel: "alternate",
        hreflang: "cs",
        href: "https://savinginsta.com/cs",
      },
      {
        rel: "alternate",
        hreflang: "de",
        href: "https://savinginsta.com/de",
      },
      {
        rel: "alternate",
        hreflang: "it",
        href: "https://savinginsta.com/it",
      },
      {
        rel: "alternate",
        hreflang: "pl",
        href: "https://savinginsta.com/pl",
      },
      {
        rel: "alternate",
        hreflang: "hu",
        href: "https://savinginsta.com/hu",
      },
      {
        rel: "alternate",
        hreflang: "nl",
        href: "https://savinginsta.com/nl",
      },
      {
        rel: "alternate",
        hreflang: "ro",
        href: "https://savinginsta.com/ro",
      },
      {
        rel: "alternate",
        hreflang: "el",
        href: "https://savinginsta.com/el",
      },
      {
        rel: "canonical",
        href: "https://savinginsta.com/jv",
      },
    ],
    script: [
      {
        json: {
          "@context": "https://schema.org",
          "@type": "WebSite",
          name: "Instagram Downloader - Download Instagram Video online - Savinginsta",
          url: "https://savinginsta.com",
          description:
            "Savinginsta: Ngundhuh video, gulungan, lan foto Instagram kanthi gampang nganggo alat sing ramah pangguna. Simpen video Instagram kanthi cepet lan aman ing piranti apa wae.",
          publisher: {
            "@type": "Organization",
            name: "Savinginsta",
            logo: {
              "@type": "ImageObject",
              url: "https://savinginsta.com/static/images/logo.webp",
            },
          },
        },
        type: "application/ld+json",
      },
    ],
  },
  data() {
    return {
      input: "",
      success: false,
      isHttpLoading: false,
      httpError1: false,
      httpError2: false,
      current: 0,
      successList: [],
      faqList: [
        {
          title: `Apa iku Instagram Video Downloader?`,
          content: `Instagram Video Downloader minangka alat basis web sing dirancang kanggo nyimpen foto, video, lan konten IGTV Instagram kanggo digunakake mengko. Savinginsta minangka pilihan utama kanggo ndownload konten saka Instagram kanthi gampang.`,
        },
        {
          title: `Apa Mlebet Akun Instagramku Perlu Kanggo Nggunakake Savinginsta?`,
          content: `Ora, ora perlu mlebu akun Instagram sampeyan. Savinginsta njamin download sing aman lan anonim saka Instagram tanpa mbutuhake informasi pribadhi.`,
        },
        {
          title: `Apa aku bisa langsung nyimpen video saka Instagram?`,
          content: `Ngundhuh video langsung saka feed Instagram utawa crita wong liya ora bisa ditindakake liwat Instagram dhewe. Nanging, Savinginsta nawakake solusi sing gampang. Cukup bukak situs web ing https://savinginsta.com lan tindakake pandhuan langsung sing diwenehake.`,
        },
        {
          title: `Apa Layanan Download Video & Foto Instagram Gratis?`,
          content: `Ya, Savinginsta nyedhiyakake layanan iki kanthi gratis, tanpa watesan babagan jumlah download.`,
        },
        {
          title: `Apa aku bisa ndownload konten saka akun Instagram pribadi?`,
          content: `Pancen, Savinginsta ngidini sampeyan ndownload video, crita, lan foto saka akun Instagram pribadi. Pandhuan rinci kasedhiya ing platform kasebut.`,
        },
        {
          title: `Apa bisa nyimpen crita Instagram?`,
          content: `Pancen. Kanthi Savinginsta, sampeyan bisa ndeleng lan ndownload crita Instagram apa wae. Cukup klik ing telung titik (⁝) ing crita, nyalin link, lan paste menyang Savinginsta kanggo miwiti download.`,
        },
        {
          title: `Apa Savinginsta Ndhukung Download ing Komputer?`,
          content: `Ya, Savinginsta kompatibel karo PC, ngidini sampeyan ndownload video Instagram, foto, crita, lan liya-liyane langsung menyang komputer.`,
        },
        {
          title: `Bisa Gunakake Savinginsta kanggo Ngundhuh saka Instagram ing Piranti Android?`,
          content: `Mesthi wae. Kanggo pangguna Android, mung nyalin link kirim Instagram, paste menyang Savinginsta, lan simpen. Kanggo rincian liyane, bukak pandhuan babagan ndownload saka Instagram ing Android.`,
        },
        {
          title: `Kepiye Cara Ngundhuh Video lan Foto Instagram ing iPhone/iPad (iOS)?`,
          content: `Savinginsta wis nggawe pandhuan langkah-langkah kanggo ndownload macem-macem jinis video menyang iPhone utawa iPad sampeyan. Tindakake link iki kanggo instruksi: Download Video Instagram ing iPhone.`,
        },
        {
          title: `Kepiye Yen Video Instagram Diputer tinimbang Ngundhuh?`,
          content: `Kanggo ngatasi masalah iki, klik-tengen ing video banjur pilih 'Simpen Minangka...' kanggo milih lokasi nyimpen sing dikarepake, tinimbang ngeklik ngiwa.`,
        },
        {
          title: `Ngendi Video Disimpen Sawise Diundhuh?`,
          content: `Video sing diundhuh biasane disimpen ing folder 'Unduh' ing piranti seluler lan PC Android.`,
        },
      ],
    };
  },
  computed: {
    ...mapGetters(["language"]),
  },
  mounted() {
    this.debouncedDownInput = this.debounce(this.downInput, 1000);

    //到达首页
    handleClick("guide_homepage_frist", {});
    handleClick("guide_homepage", {});
  },
  methods: {
    async downloadHandel() {
      if (this.isHttpLoading || this.input === "") return;
      this.isHttpLoading = false;
      this.httpError1 = false;
      this.httpError2 = false;
      this.input = this.input.replace(/^.*\s?https:\/\//, "https://");
      const insUrlPattern = new RegExp("^http(s|)://.*instagram.com.*/.*$");
      let type = checkString(this.input);
      if (!insUrlPattern.test(this.input)) {
        //点击解析下载按钮
        handleClick("action_ins_detect_boinsom", {
          site: "other",
          noislink: this.input,
          from: "video",
          type: type,
        });
        this.httpError2 = true;
        this.isHttpLoading = false;
        return;
      }
      //点击解析下载按钮
      handleClick("action_ins_detect_boinsom", {
        site: "other",
        from: "video",
        type: type,
      });
      //开始解析  ins_start_resolve
      handleClick("ins_start_resolve", {
        islink: this.input,
        from: "video",
        type: type,
      });
      this.isHttpLoading = true;
      try {
        let result = this.uki(this.input);
        const response = await fetch(
          "https://savinginsta.com/api/downloader/analysis",
          {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({
              path: result,
            }),
          }
        );
        let encryptedResponse = await response.text();
        let parse = JSON.parse(encryptedResponse);
        if (parse.code != 200) {
          // 解析失败  ins_resolve_fail
          handleClick("ins_resolve_fail", {
            reason: "Failed to fetch",
            islink: this.input,
            from: "video",
            type: type,
          });
          this.httpError1 = true;
          this.isHttpLoading = false;
          return;
        } else {
          //解析成功  ins_resolve_success
          handleClick("ins_resolve_success", {
            type: type,
            from: "video",
          });
          let decryptedResponse = await this.eki(parse.data); // 使用你的解密函数
          this.successList = JSON.parse(decryptedResponse);
          this.success = true;
          this.isHttpLoading = false;
        }
      } catch (error) {
        // 解析失败  ins_resolve_fail
        handleClick("ins_resolve_fail", {
          reason: "Failed to fetch",
          islink: this.input,
          from: "video",
          type: type,
        });
        console.error(error);
        this.httpError1 = true;
        this.isHttpLoading = false;
      }
    },

    uki(input) {
      let CIPHER_ALGORITHM = "DES-CBC";
      let IV_SIZE = 8;
       
      
  try {
        const complexKey = [
          process.env.part1,
          process.env.part2,
          process.env.part3,
          process.env.part4,
          process.env.part5,
          process.env.part6,
          process.env.part7,
          process.env.part8,
        ].join("");
        const keyBytes = CryptoJS.enc.Utf8.parse(complexKey);
        const inputBytes = CryptoJS.enc.Utf8.parse(input);
        const ivBytes = CryptoJS.lib.WordArray.random(IV_SIZE);
        const encrypted = CryptoJS.DES.encrypt(inputBytes, keyBytes, {
          iv: ivBytes,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad.Pkcs7,
        });
        const ciphertext = ivBytes.concat(encrypted.ciphertext);
        return ciphertext.toString();
      } catch (error) {
        console.error(error);
        return null;
      }
    },
    eki(cipherText) {
      let CIPHER_ALGORITHM = "DES-CBC";
      let IV_SIZE = 8;
       
      const complexKey = [
          process.env.part1,
          process.env.part2,
          process.env.part3,
          process.env.part4,
          process.env.part5,
          process.env.part6,
          process.env.part7,
          process.env.part8,
        ].join("");
      try {
        let keyBytes = CryptoJS.enc.Utf8.parse(
          complexKey.padEnd(CIPHER_ALGORITHM === "DES-CBC" ? 8 : 16)
        );
        let ivBytes = { iv: CryptoJS.enc.Hex.parse(process.env.DES_IV) }; // 如果使用CBC模式，需要一个初始化向量iv，这里是空向量
        let decrypted = CryptoJS.DES.decrypt(
          { ciphertext: CryptoJS.enc.Hex.parse(cipherText) },
          keyBytes,
          ivBytes
        );
        return decrypted.toString(CryptoJS.enc.Utf8);
      } catch (e) {
        console.error(e);
        return null;
      }
    },
    sendDownload(event) {
      if (event.keyCode === 13 && !this.isHttpLoading) {
        this.downloadHandel();
        event.preventDefault();
        return false;
      }
    },
    changeTab(k) {
      this.current = k;
    },
    handleInput(e) {
      this.debouncedDownInput(e);
    },
    debounce(fn, delay) {
      let timer;
      return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(() => {
          fn.apply(context, args);
        }, delay);
      };
    },

    downInput(e) {
      let type = checkString(e.target.value);
      // 粘贴链接到输入框 action_ins_paste
      handleClick("action_ins_paste", {
        islink: e.target.value,
        from: "photo",
        type: type,
      });
    },
    handleClickPasted() {
      if (!navigator.clipboard) {
        console.log("Clipboard API not available");
        return;
      }
      navigator.clipboard
        .readText()
        .then((text) => {
          this.input = text;
          let type = checkString(text);
          // 粘贴链接到输入框 action_ins_paste
          handleClick("action_ins_paste", {
            islink: text,
            from: "photo",
            type: type,
          });
        })
        .catch((err) => {
          console.error("Failed to read clipboard contents: ", err);
        });
    },
    showLanguageHandel() {
      this.$refs.languageRef.close();
    },
    refresh() {
      this.success = false;
      this.input = "";
      this.successList = [];
    },
    goToTop(site) {
      //切换页面
      handleClick("action_page_switch", {
        site: site,
        from: top,
      });
    },
    goToTools(site) {
      //切换页面
      handleClick("action_page_switch", {
        site: site,
        from: tools,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/static/style/index.css";
.loading {
  .loading-dots {
    position: relative;
    z-index: 999;
    margin-top: 70px;
  }

  .dot {
    background-color: #ffffff;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 10px;
    animation: loading-animation 1.5s infinite;
  }

  .dot:nth-child(2) {
    animation-delay: 0.5s;
  }

  .dot:nth-child(3) {
    animation-delay: 0.8s;
  }
  .dot:nth-child(4) {
    animation-delay: 1s;
  }
}
@keyframes loading-animation {
  0%,
  50%,
  80%,
  100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.5);
  }
}
@media (max-width: 768px) {
  .loading {
    .loading-dots {
      margin-top: 26px !important;
    }
    .dot {
      width: 8px !important;
      height: 8px !important;
    }
  }
}
</style>
